package dbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class MyConn extends DBI {
    Connection connection;
    private String url="jdbc:mysql:///mynew?useSSL=false&serverTimezone=Hongkong&characterEncoding=utf-8&autoReconnect=true";
    public MyConn() {
        //加载驱动
        try{
            Class.forName("com.mysql.jdbc.Driver");
        }catch (ClassNotFoundException e){
            e.printStackTrace();
        }
    }

    @Override
    public Connection getConn() throws SQLException {
         connection= DriverManager.getConnection(url,"root","123456");
        return connection;
    }

    @Override
    public void closeConn() throws SQLException {
        if (connection!=null&&connection.isClosed()){
            connection.close();
        }

    }
    public static void main(String[]args){
        try {
            System.out.println(new MyConn().getConn().isClosed());
        }catch (SQLException throwables){
            throwables.printStackTrace();
        }
    }
}
